package com.java.base.exercise.current;

/**
 * @Author RenPu
 * @Date 2022/1/11 15:22
 * @Version 1.0
 * @Description:
 **/
public class LongAdressChangeShortAddress {


    private static final String[] X36_ARRAY = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".split(",");

    public static String getShortUrl(String url) {
//        long shortUrlSeed = jedis.incr("short_url_seed");
        long shortUrlSeed = 10;



        StringBuffer buffer = new StringBuffer();
        while(shortUrlSeed > 0) {
            buffer.append(X36_ARRAY[(int)(shortUrlSeed % 36)]);
            shortUrlSeed = shortUrlSeed / 36;
        }
        //获取到短链接
        String shortUrl = buffer.reverse().toString();
        return shortUrl;
    }

    public static void main(String[] args) {
        String shortUrl = getShortUrl("http://10.106.11.64:83/jenkins/view/2.2%E6%B5%8B%E8%AF%95-%E4%BF%A1%E6%81%AF%E5%8C%96nacos-%E5%90%8E%E7%AB%AF/job/test_pub_backend_my-sc-preparation_nacos_pipeline/");
        System.out.println(shortUrl);

    }

}
